package com.project.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

@RestController
@RequestMapping("onload")
public class UploadController {
    @RequestMapping("add")
    public String upload(@RequestParam("file")MultipartFile mf)throws Exception {
        //获取名字
        String fileName =mf.getOriginalFilename();
        fileName = System.currentTimeMillis()+fileName;
        mf.transferTo(new File("D:/aProject/changku/java/src/main/resources/static/img/"+fileName));
        return fileName;
    }
}
